package online.heycm.rbac.common.type;

import lombok.Getter;
import online.heycm.platform.common.entity.exception.BizException;
import online.heycm.rbac.common.constant.ErrorCode;

import java.util.Arrays;

/**
 * 登录认证方式
 *
 * @author hey
 * @version 1.0
 * @date 2024/1/12 17:38
 */
@Getter
public enum AuthType {

    // 账户密码登录
    ACCOUNT(1),
    // 短信验证码登录
    SMS(2);

    private final int type;

    AuthType(int type) {
        this.type = type;
    }

    public static AuthType of(int type) {
        return Arrays.stream(values()).filter(e -> e.type == type).findAny().orElseThrow(() -> new BizException(ErrorCode.LOGIN_AUTH_TYPE));
    }
}
